import request from '@/utils/request'

/**
 * 获取角色列表
 * @param {*} queryObj
 * @returns
 */
export const getRoleListAPI = (queryObj) => {
  return request({
    mehtod: 'get',
    url: '/sys/role',
    params: queryObj
  })
}

/**
 * 删除角色
 ***/
export const delRoleAPI = (roleID) => {
  return request({
    method: 'delete',
    url: `/sys/role/${roleID}`
  })
}

/** *
 * 新增角色
 * ***/
export const postRoleAPI = (roleForm) => {
  return request({
    method: 'post',
    url: '/sys/role',
    data: roleForm
  })
}

/**
 * 根据 id 获取角色详情, 用于回显
 * **/
export const getRoleDetailAPI = (roleID) => {
  return request({
    method: 'get',
    url: `/sys/role/${roleID}`
  })
}

/** *
 * 修改角色
 * **/
export const putRoleAPI = (roleForm) => {
  return request({
    method: 'put',
    url: `/sys/role/${roleForm.id}`,
    data: roleForm
  })
}

// 根据 id 查询企业
export const getCompanyDetailAPI = (companyID) => {
  return request({
    method: 'get',
    url: `/company/${companyID}`
  })
}

/**
 * 给角色分配权限
 * @param {*} id
 * @param {*} permIds
 * @returns
 */
export const putAssinRoleAPI = (id, permIds) => {
  return request({
    method: 'put',
    url: '/sys/role/assignPrem',
    data: {
      id,
      permIds
    }
  })
}
